package net.wangds.utils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

/**
 * Json工具类.
 */
public final class JsonUtils {

    public static String toJsonStr(Object target){
        return new Gson().toJson(target);
    }

    public static <T> T fromJsonStr(String str, Class<T> clz){
        return new Gson().fromJson(str, clz);
    }


    public static <T> T fromJsonStr(String str, TypeToken<T> typeToken){

        return new Gson().fromJson(str, typeToken.getType());
    }

}
